package com.app.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.app.entity.Company;
import com.app.service.CompanyService;

@SuppressWarnings("serial")
@Scope("prototype")
@Controller
public class CompanyAction extends BaseActionSupport<Company> {
	private String keyWord;
	private Company company = new Company();

	@Autowired
	private CompanyService companyService;


	protected void prepareModel() throws Exception {
		if (id != null)
			company = companyService.load(id);
		else 
			company = companyService.findComany();
	}

	public String saveOrUpdate() throws Exception {
		companyService.updateCompany(company);
		return SUCCESS;
	}

	public Company getModel() {
		return company;
	}

	public String getKeyWord() {
		return keyWord;
	}

	public void setKeyWord(String keyWord) {
		this.keyWord = keyWord;
	}
}
